package com.ctibook.booksystem.cxf.handler;

import javax.xml.bind.ValidationEvent;
import javax.xml.bind.ValidationEventHandler;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class IgnoreUnexpectedElementValidationEventHandler implements
		ValidationEventHandler {
	private static final Log log = LogFactory
			.getLog(IgnoreUnexpectedElementValidationEventHandler.class);

	@Override
	public boolean handleEvent(ValidationEvent event) {
		String msg = event.getMessage();
		if (msg != null) {
			if (msg.toLowerCase().startsWith("unexpected element")
					|| msg.toLowerCase().startsWith("意外的元素 (uri")) {
				log.warn(msg);
				return true;
			}
		}
		return false;
	}

}
